package _0125;

/**
 * Created by HMF on 2021/05/23 22:39
 */

/**
 * 0125.验证回文串
 */
public class Solution {
    public static boolean isPalindrome(String s) {
        StringBuffer sb_s = new StringBuffer(); // 包含字母和数字的字符串
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(Character.isLetterOrDigit(ch)){
                sb_s.append(Character.toLowerCase(ch));
            }
        }
        StringBuffer sb_reverse = new StringBuffer(sb_s).reverse();
        return sb_s.toString().equals(sb_reverse.toString());
    }


    public static void main(String[] args) {
//        String str = "A man, a plan, a canal: Panama";
//        String str = "race a car";
//        String str = "A man: nam, a";
//        String str = ".,";
//        String str = "acb;aab:ca";
        String str = ".";
        char ch_a = 'a'; // 97
        char ch_z = 'z'; // 122
        char ch_A = 'A'; // 65
        char ch_Z = 'Z'; // 90
        char ch_0 = '0'; // 48
        char ch_9 = '9'; // 57
        System.out.println(str + " \n是回文串吗？ \n" + isPalindrome(str));
        System.out.println("1/2=" + 1 / 2 + "\n3/2=" + 3 / 2 + "\n4/2=" + 4 / 2);
    }
}
